﻿<UserControl x:Class="Citrix.XaAdminMobile.ViewCommon.SettingsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"
             FocusVisualStyle="{x:Null}"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:vm="clr-namespace:Citrix.XaAdminMobile.ViewModel"
             xmlns:prop="clr-namespace:Citrix.XaAdminMobile.Properties"
             xmlns:cmp="clr-namespace:Citrix.Cmp;assembly=Citrix.Cmp.Wpf"
             >
  
  <UserControl.Resources>

    <Style x:Key="BubbleContentHeaderTextStyle" TargetType="{x:Type TextBlock}">
      <Setter Property="FontSize" Value="16"/>
      <Setter Property="FontWeight" Value="Bold"/>
      <Setter Property="Foreground" Value="#FF3B3B3B"/>
      <Setter Property="Effect">
        <Setter.Value>
          <DropShadowEffect Direction="90" Color="LightGray" ShadowDepth="1" BlurRadius="0"/>
        </Setter.Value>
      </Setter>
    </Style>
    
    <!-- For showing a server in our list. -->
    <DataTemplate DataType="{x:Type vm:ServerItemViewModel}">
      <TextBlock FontSize="22" Margin="15,8" Text="{Binding Name}"/>
    </DataTemplate>

    <!-- Displays the special "add server" button at the bottom of the list. We use a control
    template rather than just setting the content because we don't have an existing button
    style that quite matches what we need. -->
    <DataTemplate DataType="{x:Type vm:AddServerItemViewModel}">
      <Button x:Name="AddButton" Padding="15,8" HorizontalContentAlignment="Stretch" Foreground="Black"
              Command="{Binding AddServerCommand}">
        <Button.Template>
          <ControlTemplate TargetType="{x:Type Button}">
            <Grid>
              <!-- Transparent surface to give the button a full rectangular hit area and display
              a selection highlight. -->
              <Rectangle x:Name="Highlight" Fill="{DynamicResource ActiveSelectionHighlight}" Opacity="0"/>

              <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                    Margin="{TemplateBinding Padding}">
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*"/>
                  <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <!-- Prompt -->
                <TextBlock x:Name="Prompt" FontSize="22" FontWeight="Normal" Text="{x:Static prop:Resources.AddServerItemLabel}"/>

                <!-- Right arrow to indicate a new page is opened. -->
                <Path x:Name="ArrowPath" Style="{DynamicResource NextPageArrowStyle}"
                      Grid.Column="1" Margin="10,0" VerticalAlignment="Center"/>
              </Grid>
            </Grid>
            <ControlTemplate.Triggers>
              <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="DarkGray"/>
              </Trigger>
              <!-- Show a background highlight while pressed and set the foreground of all items
              to white. -->
              <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="Prompt" Property="Foreground" Value="White"/>
                <Setter TargetName="ArrowPath" Property="Stroke" Value="White"/>
                <Setter TargetName="Highlight" Property="Opacity" Value="100" />
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Button.Template>
      </Button>
    </DataTemplate>
  </UserControl.Resources>
  
  <Grid Background="{DynamicResource BubbleBackgroundBrush}">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!-- The master nav toolbar -->
    <ContentPresenter Content="{Binding NavToolbarViewModel}" />

    <!-- Scrollable content -->
    <ScrollViewer Grid.Row="1">
      <Grid>

        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Margin="15,10,0,0" Text="{x:Static prop:Resources.ServerConfigTitle}"
                   Style="{DynamicResource BubbleContentHeaderTextStyle}"/>
        <cmp:ClippingBorder Grid.Row="1" BorderBrush="Gray"
                          Background="White"
                          Margin="10,5,10,10" CornerRadius="10"
                          BorderThickness="1" SnapsToDevicePixels="True"
                          VerticalAlignment="Top">
          <ListBox Style="{DynamicResource CleanListboxStyle}"
                   HorizontalContentAlignment="Stretch"
                   ScrollViewer.VerticalScrollBarVisibility="Disabled"
                   ItemContainerStyle="{DynamicResource NoLastSeparatorListBoxItem}"
                   SelectedItem="{Binding SelectedItem}"
                   ItemsSource="{Binding AvailableServers}"/>
        </cmp:ClippingBorder>
      </Grid>
    </ScrollViewer>
    
  </Grid>
</UserControl>
